package com.njupt.simulation.utils;

import lombok.Getter;
import lombok.Setter;

public class CalculateDistance {
    public static double calculateDistance(Position coordinates1, Position coordinates2) {
        //coordinates1[0]经度  coordinates1[1]纬度  coordinates1[2]高度
        //coordinates2[0]经度  coordinates2[1]纬度  coordinates2[2]高度

        double[] Object1 = CoordinateTransform.coordinatetransform(coordinates1.longitude,coordinates1.latitude,coordinates1.height);
        double[] Object2 = CoordinateTransform.coordinatetransform(coordinates2.longitude,coordinates2.latitude,coordinates2.height);

        //获取对象1转换之后的坐标
        double x1 = Object1[0];
        double y1 = Object1[1];
        double z1 = Object1[2];
        //获取对象2转换之后的坐标
        double x2 = Object2[0];
        double y2 = Object2[1];
        double z2 = Object2[2];
        //计算两个对象之间的距离
        double d = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2));
        return d;
    }


    private static class Position{
        double longitude;

        double latitude;

        double height;
    }



    public static void main(String[] args) {
        double[] earthA= {118.5,32,0.0655};
        double[] satB= {119,32.5,0.0655};
        double[] satA={147.753,0.134,35786};
        double[] satC= {146.253,0.134,35786};
        double[] earthC= {146.024,0.238,0.0679};
        double[] earthB= {149.030,0.160,0.0621};
//        double a1= calculateDistance(earthA,satB);
//        double a2= calculateDistance(earthC,satA);
//        double a3= calculateDistance(earthB,satA);
//
//        // 打印结果
//        System.out.println("AA星站之间距离：" + a1);
//        System.out.println("BA星站之间距离：" + a2);
//        System.out.println("CA星站之间距离：" + a3);
    }


}
